package com.areaCalc;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainMenu extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		final Button calculateAreaButton = (Button) findViewById(R.id.area_calculator_button);
		calculateAreaButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent calArea = new Intent(MainMenu.this, CalculateArea.class);
				startActivity(calArea);
			}
		});

		Button calculateDistanceButton = (Button) findViewById(R.id.distance_calculator_button);
		calculateDistanceButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent calDist = new Intent(MainMenu.this, CalculateDistance.class);
				startActivity(calDist);

			}
		});

		Button contributtorButton = (Button) findViewById(R.id.contributor_button);
		contributtorButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent developers = new Intent(MainMenu.this, Developers.class);
				startActivity(developers);					
			}
		});
	}

	public boolean onCreateOptionsMenu(Menu menu) {
		new MenuInflater(this).inflate(R.menu.initial_menu, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if (item.getItemId()== R.id.list_menu) {
			Intent viewList = new Intent(MainMenu.this, CalculationList.class);
			startActivity(viewList);
			return(true);
		}
		return super.onOptionsItemSelected(item);
	}
}